﻿function postTo(fn, params, successFn)  
{  
    var page = window.location.pathname;  
    var paramList = '';  
    if (params.length > 0)  
    {  
        for (var i=0; i<params.length; i+=2)  
        {  
            if (paramList.length > 0) 
            {
                paramList += ',';  
            }
            paramList += '"' + params[i] + '":"' + params[i+1] + '"';  
        }  
    }  
    paramList = '{' + paramList + '}';  
    $.ajax({  
        type: "POST",  
        url: page + "/" + fn,  
        contentType: "application/json; charset=utf-8",  
        data: paramList,  
        dataType: "json",  
        success: successFn,
        error: function errorFn(result){}  
    });
}